<template>
  <div>
    <el-dialog
      class="idadd"
      title="编辑限时活动"
      :visible.sync="dialogVisible"
      width="50%"
    >
      <div class="block">商品原价：{{ homeInfo.price }}</div>
      <div class="block">商品名称：{{ homeInfo.name }}</div>
      <div class="block">
        促销价格：
        <el-input-number
          v-model="tabledata.promotionPrice"
          @change="handleChange"
          :min="1"
          size="small"
          label="描述文字"
        ></el-input-number>
      </div>
      <div class="block">
        排序：
        <el-input-number
          v-model="tabledata.sort"
          @change="handleChange"
          :min="1"
          size="small"
          label="描述文字"
        ></el-input-number>
      </div>
      <div class="block">
        <span class="demonstration">开始时间:</span>
        <el-date-picker
          value-format="yyyy-MM-dd HH:mm:ss"
          v-model="tabledata.promotionStartTime"
          type="date"
          size="small"
          placeholder="选择日期"
        >
        </el-date-picker>
      </div>
      <div class="block">
        <span class="demonstration">结束时间:</span>
        <el-date-picker
          value-format="yyyy-MM-dd HH:mm:ss"
          v-model="tabledata.promotionEndTime"
          type="date"
          size="small"
          placeholder="选择日期"
        >
        </el-date-picker>
      </div>
      <div class="block">
        活动限购数量<el-input
          style="width: 200px"
          v-model="tabledata.promotionPerLimit"
          placeholder="请输入数量"
          size="small"
        ></el-input>
      </div>
      <div class="block">活动图片</div>
      <img :src="homeInfo.pic" alt="" style="width: 200px" />
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import marketing from '@/api/marketing.js'
import mixin from '@/mixins'
export default {
  mixins: [mixin],

  data() {
    return {
      dialogVisible: false,
      homeInfo: '',
      tabledata: {
        brandName: '', //品牌名称
        createTime: '',
        modifyTime: '',
        name: '', //商品名称
        pic: '', //图片
        price: '', //商品原价
        productCategoryName: '', //商品分类名称
        productId: '', //商品id
        productSn: '', //货号
        promotionEndTime: '', //促销结束时间
        promotionPerLimit: '', //活动限购数量
        promotionPrice: '', //促销价格
        promotionStartTime: '', //促销开始时间
        publishStatus: '', //上架状态  0下架 1 上架
        recommendId: '', //推荐条目id
        sort: '', //排序
        type: '', //活动类型 0限时购买 2 未定
      },
    }
  },
  created() {},
  mounted() {},
  methods: {
    submit() {
      this.dialogVisible = false
      marketing
        .addRecommendApi({
          price: this.homeInfo.price,
          pic: this.homeInfo.pic,
          name: this.homeInfo.name,
          promotionPrice: this.tabledata.promotionPrice,
          sort: this.tabledata.sort,
          promotionStartTime: this.tabledata.promotionStartTime,
          promotionEndTime: this.tabledata.promotionEndTime,
          promotionPerLimit: this.tabledata.promotionPerLimit,
          productId: this.homeInfo.brandId,
        })
        .then(res => {
          console.log(res, '添加限时活动')
        })
    },
    //子组件的打开方法
    open(row) {
      console.log(row, '孙子里面的row')
      this.homeInfo = row
      this.dialogVisible = true
    },

    searchs() {
      console.log('上架')
    },
    handleChange(value) {
      console.log(value)
    },
  },
}
</script>

<style scoped lang="scss">
.idadd ::v-deep .el-dialog {
  height: 700px !important;
}
.block {
  width: 400px;
  margin-top: 30px;
  float: left;
}
</style>